;==========================================================
; GENKIDAMA KAIYOKEN HELPER

[Statedef 2936]
type = A
physics = N
movetype = A
ctrl = 0
sprpriority = 5

[state 1215, Smoke FX]
type = explod
trigger1 = time = 40
anim = 8060   ;1206+(root,var(2)=0)
id = 1206
pos = -80,70
;postype = P1
bindtime = -1
sprpriority = 6
ownpal = 1
removetime = 155
persistent = 0
ignorehitpause = 1

[state 1215, Smoke FX]
type = explod
trigger1 = time = 195
anim = 8061   ;1206+(root,var(2)=0)
id = 1206
pos = -80,70
;postype = P1
bindtime = 1
sprpriority = 6
ownpal = 1
removetime = -2
persistent = 0
ignorehitpause = 1

[State 1061, Velocity]
type = VelSet
trigger1 = !time && (var(3)<1)
x = 12
y = 3

[State 1061, Velocity];anti-misfire fix = give small velocity when hitting
type = VelSet
trigger1 = !time && (var(3)=1)
x = 6

[State 1061, Velocity]
type = VelSet
trigger1 = time=40 && (var(3)<2)
x = -5
y = 0

[State 1061, Velocity]
type = VelSet
trigger1 = pos X <= 0 && time>40 && (var(3)<2) && facing=1
trigger2 = pos X >= 0 && time>40 && (var(3)<2) && facing=-1
x = 0

[State 3005, anim]
type = changeanim
trigger1 = !time && !prevstateno
value = 2523

[State 1061, NoJuggle]
type = parentvarset
trigger1 = time = 0
v = 18
value = 1

[State 3005, hitvar]
type=varadd
trigger1= !time
var(2)=1
[State 1055, movehitvar]
type=varset
trigger1= movecontact && numtarget
trigger1= !(target,ishelper)
var(3)=1
ignorehitpause=1

[State 13100, goes SND]
type = playsnd
trigger1 = !time
value = 2000,2

[State 1061, NoShadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 1061, NoShadow]
type = Trans
trigger1 = root,var(2)=0
trans = none
ignorehitpause = 1

[State 1061, NotHitBy]
type = NotHitBy
trigger1 = Time >= 0
time = 1
value = SCA
ignorehitpause = 1

[State 1315, image]
type = afterimage
trigger1 = !time
time = 999
timegap = 1
framegap = 2
length = 5
palcontrast = 50,50,200
trans = add

[State 3005, hit]
type = hitdef
trigger1 = 1
attr = S,HP
hitflag = MAF
guardflag = MA
priority = 7,Hit
damage = 9,0
getpower = 0,0
givepower = 35,35
pausetime = 4*(var(2)<10),6
animtype = Back
air.animtype = Back
fall.animtype = Back
ground.type = High
air.type = Low
ground.hittime = 16
ground.slidetime = 16
guard.hittime = 16
air.hittime = 13
airguard.ctrltime = 16
ground.velocity = 0, ifelse(var(2)<10, 0, -12)
guard.velocity = -9
air.velocity = 0, ifelse(var(2)<10, 0, -12)
airguard.velocity = -5.5, -1.5 
ground.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
air.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
yaccel = .5
fall=(var(2)>=10)
air.fall = 1
fall.recover = 0
sparkno = -1
hitsound   = s1000,0
guardsound = S6,0
envshake.time = 16
envshake.ampl = 6
envshake.freq = 100
forcestand = 1
palfx.sinadd=64,64,64,4
palfx.mul=128,128,128
palfx.time=32
kill = 0
forcestand = 1
p1sprpriority = 5

[State 1061, NoJuggle]
type = parentvarset
trigger1 = movecontact 
v = 18
value = 0

[State 1315, Sparks]
type=explod
trigger1= movehit && numtarget
trigger1= (target,movetype=H) && !(target,time)
anim=ifelse(var(2)=10,2512,7020)
scale=ifelse(var(2)=10,1.3,1),ifelse(var(2)=10,1.3,1)   ;1.5 before
sprpriority=7
postype=p2
pos=(target,const(size.ground.front)-10),-floor(p2dist y)
removetime=-2
ownpal=1
facing=-1
ignorehitpause=1
persistent=0
pausemovetime=100
supermovetime=100

[State 13100, explosion SND]
type = playsnd
triggerall = movecontact=1 && numtarget
trigger1 =  movehit=1 && numenemy
trigger1 = var(2) = 10
value = 2511,0
volume = 355

[State 3005, end]
type = changestate
trigger1 = movecontact
value = ifelse(var(2)<10,2936,ifelse(movehit,2938,1316))

[State 3001, Guardshake]
type = envshake
trigger1 = movecontact=1 && numtarget
time = 4
ampl = 6
freq = 176
ignorehitpause = 1

;-------------------------------------
[Statedef 2938]; Genkidama Kaiyoken waits
type = A
physics = N
movetype = A
ctrl = 0
sprpriority = 5
velset = 2,0

[State 1061, not too close to edge]
type = Velset
trigger1 = FrontEdgeDist < 30
X = 0
Y = 0

[State 1061, NoShadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 1308, nothitby]
type = nothitby
trigger1 = 1
time = 1
value = SCA
ignorehitpause = 1

[State 1061, NoShadow]
type = Trans
trigger1 = root,var(2)=0
trans = none
ignorehitpause = 1

[State 3005, anim]
type = changeanim
trigger1 = !time && !prevstateno
value = 2531

[state 17100, Wave Effect]
type=explod
trigger1 = time = 25
anim=2205+(root,var(2)=1)
id=2205
pos=0,-floor(p2dist y)
postype=P1
sprpriority=7
ownpal=1
supermovetime=-1
removetime = -2

[state 17100, Wave Effect]
type=explod
trigger1 = time = 25
anim=2517
id=2205
pos=0,0
postype=P1
sprpriority=6
ownpal=1
supermovetime=-1
removetime = -2

[State 3005, end]
type = changestate
trigger1 = time > 25
value = 2939

;-------------------------------------
[Statedef 2939]; Genkidama Kaiyoken goes up
type = A
physics = N
movetype = A
ctrl = 0
sprpriority = 5
velset = 0,0

[State 3005, scale]
type = AngleDraw
trigger1 = var(2)<22
value = 0
scale = 1.1+0.08*(var(2)-10),1.1+0.08*(var(2)-10)
[State 3005, scale]
type = AngleDraw
trigger1 = var(2)=22
value = 0
scale = 2.3,2.3

[State 3005, anim]
type = changeanim
trigger1 = !time
value = 2531

[State 3005, hitvar]
type=varadd
trigger1= !time
var(2)=1

[State 1055, movehitvar]
type=varset
trigger1= movecontact && numtarget
trigger1= !(target,ishelper)
var(3)=1
ignorehitpause=1

[State 13100, goes SND]
type = playsnd
trigger1 =  !time
value = 2000,2

[State 1061, NoShadow]
type = AssertSpecial
trigger1 = 1
flag = noshadow
ignorehitpause = 1

[State 1061, NoShadow]
type = Trans
trigger1 = root,var(2)=0
trans = none
ignorehitpause = 1

[State 1061, NotHitBy]
type = NotHitBy
trigger1 = Time >= 0
time = 1
value = SCA
ignorehitpause = 1

[State 1061, Velocity]
type = VelSet
trigger1 = 1
y = ifelse((time<2 && var(2)>1),-4,-10)

[State 1315, image]
type = afterimage
trigger1 = !time
time = 999
timegap = 1
framegap = 2
length = 5
palcontrast = 50,50,200
trans = add

[State 3005, hit]
type = hitdef
trigger1 = 1
attr = S,HP
hitflag = MAF
guardflag = MA
priority = 7,Hit
damage = 14,0
getpower = 0,0
givepower = 35,35
pausetime = 8,0
animtype = Back
air.animtype = Back
fall.animtype = Back
ground.type = High
air.type = Low
ground.hittime = 16
ground.slidetime = 16
guard.hittime = 16
air.hittime = 13
airguard.ctrltime = 16
ground.velocity= ifelse(var(2)<22, ifelse(var(2)%2=0,2,-2), -2), ifelse(var(2)<22, -2, -7)
guard.velocity = -9
air.velocity =  ifelse(var(2)<22, ifelse(var(2)%2=0,2,-2), -2), ifelse(var(2)<22, -3, -7)
airguard.velocity = -5.5, -1.5 
ground.cornerpush.veloff = 0
guard.cornerpush.veloff = 0
air.cornerpush.veloff = 0
airguard.cornerpush.veloff = 0
yaccel = .5
fall=(var(2)>=22)
air.fall = 1
fall.recover = 0
sparkno = -1
hitsound   = s2400,3
guardsound = S6,0
p2facing = ifelse(var(2)=22,1,ifelse(var(2)%2=0,-1,1))
envshake.time = 16
envshake.ampl = 6
envshake.freq = 100
palfx.sinadd=64,64,64,4
palfx.mul=128,128,128
palfx.time=32
ID = 2533
kill=(var(2)>=21)  ;>=22 was fine in Winmugen, but 21 is needed in 1.0 (???)
p1sprpriority = 5

[state 1215, Horizontal lightning]
type = explod
trigger1= movehit && numtarget
trigger1= (target,movetype=H) && !(target,time)
anim = ifelse(var(2)%2=0,2515,2516)
id = 2515
pos = (target,const(size.ground.front)-20),-floor(p2dist y)+(target,const(size.mid.pos.y))
postype = p2
sprpriority = 4
ownpal = 1
removetime = -2
persistent = 0
ignorehitpause = 1
pausemovetime=100
supermovetime=100
scale = 0.6,0.6

[State 1315, Sparks]
type=explod
trigger1= movehit && numtarget
trigger1= (target,movetype=H) && !(target,time)
anim=ifelse(var(2)>=20,2512,7020)
scale=ifelse(var(2)>=20,1.6,1),ifelse(var(2)>=20,1.6,1)
sprpriority=7
postype=p2
pos=(target,const(size.ground.front)-10),-floor(p2dist y)-40*(var(2)>=20)
removetime=-2
ownpal=1
facing=-1
ignorehitpause=1
persistent=0
pausemovetime=100
supermovetime=100

[State 2500, bgpalfx1]
type = bgpalfx
trigger1 = movehit && numtarget
time = 2
color = 0
invertall = 1
ignorehitpause = 1
persistent = 0

[State 13100, explosion SND]
type = playsnd
triggerall = movecontact=1 && numtarget
trigger1 =  movehit=1 && numenemy
trigger1 = var(2) >= 20
value = 2511,0
volume = 355

[State 3005, end]
type = changestate
trigger1 = movecontact
value = ifelse(var(2)<22,2939,1316)

[State 3001, Guardshake]
type = envshake
trigger1 = movecontact=1 && numtarget
time = 4
ampl = 6
freq = 176
ignorehitpause = 1

[State 1061, End]
type = destroyself
trigger1 = pos y!=[-240,240]